/**
 * @author bipul_sinha
 * @version 1.0
 * @created 30th November, 2010.
 *
 * AddToCart
 *
 * Copyright @ 2010
 * All Rights Reserved.
 * CONFIDENTIAL AND TRADE SECRET
 */
package com.ces.knacky.controller.tools;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ces.knacky.framework.controller.ListController;
import com.ces.knacky.framework.exception.DataAccessException;
import com.ces.knacky.framework.model.IEntity;
import com.ces.knacky.model.BidWorkflowAudit;
import com.ces.knacky.model.BidWorkflowStatus;
import com.ces.knacky.services.AuctionService;
/**
 * It is used to approve bids.
 *
 * @author bipul_sinha
 *
 */
@Controller
public class ApproveBidsController extends ListController {
	/**
	 * Comma separated list of bid ids selected from the JSP page.
	 */
	private String selectedBidIds;


	@Autowired
	private AuctionService auctionService;

	/**
	 * It approves the selected bids
	 *
	 * @param 	request
	 * 			Request object to fetch session object.
	 * @return	String
	 * 			Represents View Resolver to be mapped in spring_views.xml file.
	 * @throws DataAccessException 
	 */
	@RequestMapping("/approveBids.htm")
	public String execute(HttpServletRequest request) {
		System.out.println("selectedBidIds = "+selectedBidIds);
		/*Set to store bids selected by the user. */
		auctionService.approveBid(selectedBidIds);
		listEntity = auctionService.loadPlacedBid();
		return "listBid";
	}

	/**
	 * This method is used to return comma separated list of bid ids selected by the user.
	 *
	 * @return 	String
	 * 			Represents comma separated list of bid ids selected by the user.
	 */
	public String getSelectedBidIds() {
		return selectedBidIds;
	}


	/**
	 * It is used to set/map the bid ids selected by the user.
	 *
	 * @param 	selectedBidIds
	 * 			Represents comma separated list of bid ids selected by the user.
	 */
	@ModelAttribute("selectedBidIds")
	public void setSelectedBidIds(String selectedBidIds) {
		this.selectedBidIds = selectedBidIds;
	}
	

	

}
